package com.itheima.tlias84.aop.cglib;

import org.springframework.jdbc.support.incrementer.PostgresSequenceMaxValueIncrementer;
import org.springframework.cglib.proxy.Enhancer;
public class TestCglib {
    public static void main(String[] args) {
//        //1.创建增强器对象
//        Enhancer enhancer = new Enhancer();
//        //2.设置被代理的类 相当于是 enhancer 继承 Dog类
//        enhancer.setSuperclass(Dog.class);
//        //创建方法拦截器
//        enhancer.setCallback(new EatIntereceptor());
//        //创建代理对象 相当于 Dog 的子类
//        Dog dog = (Dog) enhancer.create();
//        dog.eat();

        Enhancer enhancer = new Enhancer();
        enhancer.setSuperclass(TestCglibController.class);
        enhancer.setCallback(new EatIntereceptor());
        TestCglibController testCglibController = (TestCglibController) enhancer.create();
        testCglibController.setTestCglib();
    }

}
